[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

Form with React 用 React 做一份表單

Form with React 用 React 做一份表單

完成 week6 切版新拖延運動表單!~

完成 week6 切版新拖延運動表單!~

SQL 筆記

SQL 筆記






留言討論